#ifndef CART_H
#define CART_H

#include <QDialog>
#include <QSqlDatabase>
#include <QSqlError>
#include <QListWidget>
#include <QLabel>

namespace Ui {
class Cart;
}

class Cart : public QDialog
{
    Q_OBJECT

public:
    explicit Cart(QWidget *parent = nullptr, int userId = 0);
    ~Cart();

    void loadCartItems();

private slots:
    void on_backButton_clicked();
    void on_placeOrderButton_clicked();
    void on_removeFromCartButton_clicked();
    void on_clearCartButton_clicked();
    void on_setAddressButton_clicked();
    void disconnectAllButtons();


private:
    Ui::Cart *ui;
    int m_userId;
    QSqlDatabase m_db;
    QString getUserAddress() const;
    QString getUsername();  // 修正为返回QString，不是void

    void updateTotalPrice();

};

#endif // CART_H
